import React, { Component } from 'react'
import {connect} from 'react-redux';
import { index_action } from '../../../store/store';
class Tab extends Component {
    constructor(){
        super();
        this.state={
            actindex:0
        }
    }
    clickhand=(index)=>{
        this.props.ind(index);
        this.setState({
            actindex:index
        })
    }
    render() {
        return (
            <div className='tab'>
                {this.props.list.map((item,index)=>{
                    return (
                        <span key={index} className={this.state.actindex===index?"active":''} onClick={()=>{this.clickhand(index)}}>{item}</span>
                    )
                })}
            </div>
        )
    }
}
export default connect(
    (state)=>{
        return {

        }
    },
    (dispatch)=>{
        return {
            ind:(index)=>{
                dispatch(index_action(index))
            }
        }
    }
)(Tab)
